Skip to content

Sessions: dual-read legacy formats with corruption diagnostics - #182

Merged
oratis merged 4 commits into
mainfrom
codex/session-compat
Aug 2, 2026
Merged

Sessions: dual-read legacy formats with corruption diagnostics#182
oratis merged 4 commits into
mainfrom
codex/session-compat

Conversation

@oratis

@oratis oratis commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • add one core parser for historical core and desktop JSONL layouts
  • recover desktop metadata when the core sidecar does not exist and include those sessions in listings
  • tolerate only an interrupted final append; report middle corruption with an exact line
  • apply the same tail-vs-middle rule to the Rust desktop reader
  • verify compatibility reads do not mutate legacy bytes

Validation

  • pnpm docs:check
  • pnpm lint (3 pre-existing warnings, 0 errors)
  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • cargo check --manifest-path apps/desktop/src-tauri/Cargo.toml
  • cargo test --manifest-path apps/desktop/src-tauri/Cargo.toml (31 passed)

Stack

Depends on #181 and #180. This is the read/diagnostics slice of PR 2; canonical write normalization and single-writer ownership remain separate follow-ups.

@oratis
oratis changed the base branch from codex/runtime-safety to main August 2, 2026 06:35
@oratis
oratis marked this pull request as ready for review August 2, 2026 06:37
@oratis

oratis commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

Review: approved ✅

Scope: read-side session compatibility only — no writes, no migration. That separation is the right call and is what makes this safe to land ahead of #185's canonical writer.

What I checked

  • The tail-vs-middle corruption rule is the correct policy: an interrupted final append is the expected failure mode for an append-only JSONL writer killed mid-line, so tolerating it recovers real sessions. Middle corruption is genuinely anomalous and reporting an exact line number makes it diagnosable rather than a silent truncation.
  • Desktop metadata recovery when the core sidecar is missing means desktop-created sessions stop being invisible to CLI listings — that gap was a real user-facing symptom.
  • The same rule is applied in the Rust reader, so core and desktop agree on what "recoverable" means. Divergence there would have been a nasty long-lived bug.
  • The explicit test that compatibility reads do not mutate legacy bytes is the assertion I most wanted to see. Read-path code that quietly rewrites what it parses is how session history gets destroyed; pinning it in a test is the right defence.

Note: this PR deliberately leaves canonical write normalization and single-writer ownership to #185. Reviewing them together, the split holds — nothing here presumes the writer contract.

Validation: CI green. cargo test 31 passing per the PR body; full suite green locally at the stack tip.

@oratis
oratis merged commit f4dee3e into main Aug 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant